writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString) 您所在的位置:网站首页 kernel32 writefile writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString)

writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString)

#writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString)| 来源: 网络整理| 查看: 265

writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString)  

大家好,最近很多小伙伴想了解writeprivateprofilestring,下面是(www.lingziw.com)小编整理的与writeprivateprofilestring相关的内容分享给大家,一起来看看吧。

本文目录一览:

1、WritePrivateProfileString函数不能写入ini文件,该怎么处理 2、c# WritePrivateProfileString修改配置文件,出现重复的组名 3、[DllImport("kernel32")] WritePrivateProfileString WritePrivateProfileString函数不能写入ini文件,该怎么处理

配置文件中经常用到ini文件,在VC中其函数分别为:

写入.ini文件:

BOOL WritePrivateProfileString(

LPCTSTR lpAppName, // INI文件中的一个字段名[节名]可以有很多个节名

LPCTSTR lpKeyName, // lpAppName 下的一个键名,也就是里面具体的变量名

LPCTSTR lpString, // 键值,也就是数据

LPCTSTR lpFileName // INI文件的路径

);

读取.ini文件:

DWORD GetPrivateProfileString(

LPCTSTR lpAppName, // INI文件中的一个字段名[节名]可以有很多个节名

LPCTSTR lpKeyName, // lpAppName 下的一个键名,也就是里面具体的变量名

LPCTSTR lpDefault, // 如果lpReturnedString为空,则把个变量赋给lpReturnedString

LPTSTR lpReturnedString, // 存放键值的指针变量,用于接收INI文件中键值(数据)的接收缓冲区

DWORD nSize, // lpReturnedString的缓冲区大小

LPCTSTR lpFileName // INI文件的路径

c# WritePrivateProfileString修改配置文件,出现重复的组名

ArrayList al=new ArrayList();

do

{

产生一组随机数;

if(!al.Contains(你新产生的那组随机数))

{

al.add(你新产生的那组随机数);

}

}

while(al.Contains(你新产生的那组随机数))

[DllImport("kernel32")] WritePrivateProfileString

int Internal;

int InternalHigh;

int Offset;

int OffSetHigh;

int hEvent;

}

[System.Runtime.InteropServices.DllImport("kernel32.dll")]

private static extern int CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile);

[System.Runtime.InteropServices.DllImport("kernel32.dll")]

private static extern bool WriteFile(int hFile, byte[] lpBuffer, int nNumberOfBytesToWrite, out int lpNumberOfBytesWritten, out OVERLAPPED lpOverlapped);

[System.Runtime.InteropServices.DllImport("kernel32.dll")]

private static extern bool CloseHandle(int hObject);

private int iHandle;

public bool Open()

{

iHandle = CreateFile("LPT1:", (uint)FileAccess.ReadWrite, 0, 0, (int)FileMode.Open, 0, 0);

if (iHandle != -1)

{

return true;

}

else

{

return false;

}

writeprivateprofilestring([DllImport("kernel32")] WritePrivateProfileString)

以上就是writeprivateprofilestring的介绍,希望能对大家有所帮助。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有